package com.bdqn.design.singleton;

/**
 * SingletonTest
 *
 * @author LILIBO
 * @since 2024/7/6
 */
public class Singleton {

    // 该类的唯一对象
    private static Singleton instance = null;

    // ① 将构造函数私有化
    private Singleton() {
    }

    // ② 提供公开的获取对象的方法
    public static synchronized Singleton getInstance() {
        if (instance == null) {
            instance = new Singleton();
        }
        return instance;
    }

}
